<template>
  <div class="train-city">
    <h3>父组件传给子组件的toCity:{{sendData}}</h3>
    <button @click="select(`上海`)">点击此处将“上海”发射给父组件</button>
  </div>
</template>

<script>
export default {
  components: {},
  props: ["sendData"], // 用来接收父组件传给子组件的数据
  data() {
    return {};
  },
  watch: {},
  computed: {},
  methods: {
    select(val) {
      let data = {
        cityname: val
      };
      this.$emit("showCityname", data); //select事件触发后，自动触发showCityname事件
    }
  },
  created() {},
  mounted() {}
};
</script>
<style scoped>
</style>